package coroutines.exceptions

import kotlinx.coroutines.*
import java.lang.AssertionError

class CoroutineExceptionHandlerTest {
}

fun main() {
    runBlocking {
        val handler = CoroutineExceptionHandler{_, exception ->
            println("Caught $exception")
        }

        val job = GlobalScope.launch(handler) {
            throw AssertionError()
        }

        /**
         *
         * */
        val deffered = GlobalScope.async(handler) {
            throw ArithmeticException()
        }

        deffered.await()

        joinAll(job, deffered)
    }
}